package com.example.weatherapp1.data.model

import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey


@Entity(
    tableName = "saved_weather",
    foreignKeys = [ForeignKey(
        entity = City::class,
        parentColumns = ["id"],
        childColumns = ["cityId"],
        onDelete = ForeignKey.CASCADE
    )],
    indices = [Index(value = ["cityId"])]  // 为外键cityId添加索引
)
data class SavedWeather(
    @PrimaryKey(autoGenerate = true) val id: Int = 0,
    val cityId: Int,
    val temperature: Double,
    val skyCon: String,
    val updateTime: Long,
    val weatherJson: String // 存储完整的天气数据JSON
)
